<?php
/**
 * Tickmark a Task.
 * 
 * This interface should be used to mark tasks, this will change
 * the task status to 'closed'
 * 
 * @author Xavier VILAIN
 * @package Shama\Task
 * @license
 * 
 */
use Shama\Task;
$xview = Xview::instance();
$id = $xview->val('taskid');
try {
	$task = Fox\Dao::load(Task::className(), $id);
	if($task->exists()) {
		$task->setFields(array(
		'status' => Task::STATUS_CLOSED,
		'duetdate' => Task::sqlDateTime(time())
		));
		$task->prepareUpdate(Task::CHANGE_DEFAULT);
		$task->update();
		Fox\Message::Success(Msg(Hive::BUNDLE,Hive::TASK_MARK_AS_DONE));
	} else {
		Fox\Message::Warning(Msg(Hive::BUNDLE,Hive::TASK_NOT_FOUND));
	}

} catch (Fox\Object\Exception\Save $e) {
	Fox\Message::Error($e);
}
echo $xview->messages(true,true);